package com.yeyks.mattress.controller;

import cn.hutool.extra.servlet.ServletUtil;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.commonReference.append.mattress.wechat.service.MattressPayService;
import com.yeyks.mattress.param.PayControllerCreateMattressPayOrderParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Api(tags = "支付模块", description = "支付模块")
@RestController
@RequestMapping("/mattress/pay")
public class PayController {

    @Autowired
    private MattressPayService mattressPayService;

    @ApiOperation(value = "创建支付订单:v1.0.0")
    @RequestMapping(value = "/createMattressPayOrder", method = {RequestMethod.POST})
    public AjaxResponseBody<Map<String, Object>> createMattressPayOrder(HttpServletRequest request, @Validated PayControllerCreateMattressPayOrderParam param) {
        param.setIp(ServletUtil.getClientIP(request));
        Map<String, Object> vo = mattressPayService.createMattressPayOrder(param);
        return AjaxResponseBody.success(vo);
    }

}
